#!/bin/sh
. /etc/nap.conf

mounted=`mount | cut -d' ' -f1`

case `echo "$1" | cut -d' ' -f1` in
	"peer")
		# peer __ip___ ... other stuff ...
		where=`echo "$1" | cut -d' ' -f2`
		ip=`echo "$where" | sed 's/[^0-9\.]//g'`
		if [ "$ip" != "" ]
		then
			wget -q -O - "http://$ip/getmusiclist.cgi" 2>/dev/null | sort
		fi
	;;
	"sdcard")
		# sdcard __________
		where=`echo "$1" | cut -d' ' -f2`
		dir=/mnt/sd
	;;
	"usb")
		# usb drive ____________
		where=`echo "$1" | cut -d' ' -f3`
		dir=/mnt/udisk
	;;
	*)
esac

if [[ -e "$where" ]]
then
	echo "$mounted" | grep "$where" > /dev/null 2>&1
	if [[ $? = 0 ]] ; then umount "$where"; fi
	mount "$where" "$dir"
	find "$dir" -name '*.mp3' | sort
fi

